﻿using Durian.API.Application.Commands.Process;
using IMES.Common.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Durian.API.Controllers
{
    /// <summary>
    /// 工序管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessController : ControllerBase
    {
        private readonly IMediator mediator;

        public ProcessController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 工序管理添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> Handle(ProcessManagementCreateCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 工序管理显示和查询
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> Handle1(ProcessManagementSelectCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 日志显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> Handle2(ProcessLogSelectCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
